package org.seamon.management.sms;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author Simon
 */
@Component
public class SmsClient {
    @Value("${aliyun.sms.region}")
    private String regionId;
    @Value("${aliyun.sms.access-key-id}")
    private String accessKeyId;
    @Value("${aliyun.sms.access-key-secret}")
    private String accessKeySecret;
    @Value("${aliyun.sms.endpoint}")
    private String endpoint;

    public Client createClient() throws Exception {
        Config config = new Config()
                .setRegionId(regionId)
                .setAccessKeyId(accessKeyId)
                .setAccessKeySecret(accessKeySecret)
                .setEndpoint(endpoint);

        return new Client(config);
    }
}
